import { baseUrl } from "./config.js";
import Axios from "axios";

Axios.defaults.baseURL = baseUrl;

export let bindWeChatForOpenId = (userType, username, password, openid) => {
    return (
        Axios.post("weChatSystem/bindWeChatForOpenId", {
            type: userType,
            username: username,
            password: password,
            weChatIdForSendMsg: openid
        })
    );
};

export let getAccessTokenForOpenId = (code) => {
    return (
        Axios.get("weChatSystem/getAccessTokenForOpenId", {
            params: {
                code: code
            }
        })
    );
};

export let getUserWechatInfo = (accessToken, openid) => {
    return (
        Axios.get("weChatSystem/getUserWeChatInfo", {
            params: {
                accessToken: accessToken,
                openid: openid
            }
        })
    );
};

export let getUserWechatInfoStudent = (accessToken, openid) => {
    return (
        Axios.get("weChatSystem/getUserWechatInfoStudent", {
            params: {
                accessToken: accessToken,
                openid: openid
            }
        })
    );
};

export let getUserInfoByWeChatIdForSendMsg = (openid) => {
    return (
        Axios.post("weChatSystem/getUserInfoByWeChatIdForSendMsg", {
            weChatIdForSendMsg: openid
        })
    );
};

export let getUserInfoStudentByWeChatIdForSendMsg = (openid) => {
    return (
        Axios.post("weChatSystem/getUserInfoStudentByWeChatIdForSendMsg", {
            weChatIdForSendMsg: openid
            
        })
    );
};

export let deleteWechatIdForSendMsg = (openid) => {
    return (
        Axios.post("weChatSystem/deleteWeChatIdForSendMsg", {
            weChatIdForSendMsg: openid
        })
    );
};

export let deleteWechatIdStudentForSendMsg = (openid, studentName, studentLength, imageUrl) => {
    return (
        Axios.post("weChatSystem/deleteWechatIdStudentForSendMsg", {
            weChatIdForSendMsg: openid,
            studentName: studentName,
            studentLength: studentLength,
            imageUrl: imageUrl
        })
    );
};

export let getSafetySceneById = (id) => {
    return (
        Axios.post("weChatSystem/getSafetySceneById", {
            id: id
        })
    );
};

export let getSafetySceneDeal = (id) => {
    return (
        Axios.post("weChatSystem/getSafetySceneDeal", {
            id: id
        })
    );
};

export let bindStudentApi = (formData) => {
    return (
        Axios({
            method: 'post',
            url: 'weChatSystem/bindWeChatForOpenIdStudent',
            headers: { "Content-Type": "multipart/form-data" },
            processData: false,
            data: formData 
        })
    );
}

export let ConnectionApi = () => {
    return (
        Axios.get("weChatSystem/getConnectionForSelect")
    );
}

// export let uploadFile = (files) => {
//     return (
//         Axios({
//             method: 'post',
//             url: 'weChatSystem/fileUpload',
//             headers: { "Content-Type": "multipart/files" },
//             processData: false,
//             data: files 
//         })
//     );
// }




